<template>
    <div class="order-report-store-agent">
        <iframe class="service" :src="src" width="100%" height="100%"></iframe>
    </div>
</template>

<script type="text/ecmascript-6">
export default {
    data: function () {
        return {
            hasLoad: false,
            src: ''
        }
    },
    mounted () {

    },
    created () {
        window.addEventListener('message', this.handleMessage)
        let tokens = localStorage.AuthorizationToken2
        let lastIndex = this.ip.lastIndexOf('/')
        let src = this.ip.slice(0, lastIndex) + '/addService/#/mainPage/addedServices'
        let { timestamp, signature } = this.returnTimestampSignature('999999')
        let source = 3
        if (this.roleId === 1) {
            source = 5
        }
        // todo
        // src = 'http://localhost:9012/addService/#/mainPage/addedServices'
        src += '?IsImplant=1&theme=#409eff'
        src += '&tokens=' + tokens
        src += '&timestamp=' + timestamp
        src += '&signature=' + signature
        src += '&companyCode=999999'
        src += '&companyName=999999'
        src += '&agentId=' + this.$store.state.agentIdFY
        src += '&agentName=' + this.$store.state.userName
        src += '&roleId=' + this.roleId
        src += '&source=' + source
        this.src = src
        console.log(this.src)
    },
    watch: {
    },
    components: {
    },
    props: {
    },
    computed: {
        ip () {
            return this.$store.state.IP
        },
        roleId () {
            return this.$store.state.roleId
        }
    },
    methods: {
        handleMessage (event) {
            console.log(event.data, '接受值')
            this.$store.dispatch('setKA', 0)
        }
    }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
.order-report-store-agent
    width: 100%

.service
    min-height: calc(100vh - 80px)
    height: -webkit-fill-available
</style>
